﻿using ET.Monitor.DAL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ET.Monitor.Model
{
    public class AssetsModel
    {
        AssetsDAL dal = new AssetsDAL();
        string idKey, id, startDate, endDate, dueDate, date, userName, contractName, contractPhone, contractEmail, machineId, warrantyDate, typeId;
        string orgid, uname, machid, ctctname, ctctphone, ctctmail, userid, companyid, typeid, equiptype;
        float income, amountPaid, warrantyPeroid, unitPrice, paymentAmount;
        float pce, period;
        int pCount = 1, pInde = 1, quantity;
        int qtty;

        DateTime sTime = new DateTime();
        DateTime eTime = new DateTime();
        DateTime ttime, wattyme;

        public AssetsModel()
        {
        }

        public AssetsModel(string id)
        {
            this.id = id;
        }

        public AssetsModel(string companyid, string typeid){
            this.companyid = companyid;
            this.typeid = typeid;
        }
        public AssetsModel(string key, string id, string date)
        {
            this.idKey = key;
            this.id = id;
            this.date = date;
        }

        public AssetsModel(string orgid, int qtty, string machid) {
            this.orgid = orgid;
            this.qtty = qtty;
            this.machid = machid;
        }

        public AssetsModel(string orgid, DateTime ttime, int qtty, string uname, string machid)
        {
            this.orgid = orgid;
            this.ttime = ttime;
            this.qtty = qtty;
            this.uname = uname;
            this.machid = machid;
        }

        public AssetsModel(string id, string startTime, string endTime, string dueDate, float revenue, float amountPaid)
        {
            this.id = id;
            this.startDate = startTime;
            this.endDate = endTime;
            this.dueDate = dueDate;
            this.income = revenue;
            this.amountPaid = amountPaid;
        }
        public AssetsModel(string orgid, DateTime ttime, string uname, int qtty, string machid, float pce, float period, DateTime wattyme, string ctctname, string ctctphone, string ctctmail)
        {
            this.orgid = orgid;
            this.ttime = ttime;
            this.uname = uname;
            this.qtty = qtty;
            this.machid = machid;
            this.pce = pce;
            this.period = period;
            this.wattyme = wattyme;
            this.ctctname = ctctname;
            this.ctctphone = ctctphone;
            this.ctctmail = ctctmail;
        }

        public AssetsModel(string orgid, string purchaseTime, string userName, int quantity, string machineId, float price, float warrantyPeriod, string warrantyDate, string contractName, string contractPhone, string contractEmail)
        {
            this.orgid = orgid;
            this.startDate = purchaseTime;
            this.userName = userName;
            this.quantity = quantity;
            this.machineId = machineId;
            this.unitPrice = price;
            this.warrantyDate = warrantyDate;
            this.warrantyPeroid = warrantyPeriod;
            this.contractName = contractName;
            this.contractPhone = contractPhone;
            this.contractEmail = contractEmail;
        }

        public AssetsModel(string orgid, int quantity, string machineId, string purchaseDate, float paymentAmount, string dueDate)
        {
            this.orgid = orgid;
            this.quantity = quantity;
            this.machineId = machineId;
            this.date = purchaseDate;
            this.dueDate = dueDate;
            this.paymentAmount = paymentAmount;
        }

        public AssetsModel(string orgId, string typeId, float paymentAmount, string dueDate)
        {
            this.orgid = orgId;
            this.typeId = typeId;
            this.paymentAmount = paymentAmount;
            this.dueDate = dueDate;
        }
        public AssetsModel(int pageCount, int pageIndex, string orgId, DateTime st, DateTime et)
        {
            id = orgId;
            pCount = pageCount;
            pInde = pageIndex;
            sTime = st;
            eTime = et;
        }

        #region 获得Ztree数据
        DataTable im;
        public DataTable Im
        {
            get { return dal.Eqpnameforztree(); }
            set { im = value; }
        }
        #endregion

        #region 库存管理详细信息
        DataTable isear;

        public DataTable Isear
        {
            get { return dal.InstockSearch(id); }
            set { isear = value; }
        }
        #endregion

        DataTable isearorg;

        public DataTable Isearorg {
            get { return dal.InstockSearchOrg(id); }
            set { isearorg = value; }
        }


        #region 下拉框
        DataTable unitTypeForInstock;
        public DataTable UnitTypeForInstock
        {
            get { return dal.GetUnitTypeForInstock(companyid, typeid); }
            set { unitTypeForInstock = value; }
        }

        DataTable unitTypeForOutstock;

        public DataTable UnitTypeForOutstock
        {
            get { return dal.GetUnitTypeForOutstock(companyid, typeid); }
            set { unitTypeForOutstock = value; }
        }

        DataTable manufactoryForInstock;

        public DataTable ManufactoryForInstock
        {
            get { return dal.GetManufactoryForInstock(id); }
            set { manufactoryForInstock = value; }
        }

        DataTable manufactoryForOutstock;

        public DataTable ManufactoryForOutstock
        {
            get { return dal.GetManufactoryForOutstock(id); }
            set { manufactoryForOutstock = value; }
        }

        DataTable getEquiptypeForInstock;

        public DataTable GetEquiptypeForInstock
        {
            get { return dal.GetEquiptypeForInstock(); }
            set { getEquiptypeForInstock = value; }
        }

        DataTable getEquiptypeForOutstock;

        public DataTable GetEquiptypeForOutstock
        {
            get { return dal.GetEquiptypeForOutstock(); }
            set { getEquiptypeForOutstock = value; }
        }

        #endregion

        #region Instock, Outstock
        bool istk;
        public bool Istk
        {
            get { return dal.Instock(orgid, ttime, uname, qtty, machid, pce, period, wattyme, ctctname, ctctphone, ctctmail); }
            set { istk = value; }
        }

        bool ostk;

        public bool Ostk
        {
            get { return dal.Outstock(orgid, ttime, qtty, uname, machid); }
            set { ostk = value; }
        }

        bool insertinventory;

        public bool Insertinventory
        {
            get { return dal.InsertInventory(orgid, qtty, machid); }
            set { insertinventory = value; }
        }

        bool updateinven;

        public bool Updateinven
        {
            get { return dal.UpdateInventory(orgid, qtty, machid); }
            set { updateinven = value; }
        }

        bool updateinvenout;

        public bool Updateinvenout
        {
            get { return dal.UpdateInventoryOut(orgid,qtty,machid); }
            set { updateinvenout = value; }
        }

        DataTable dttb;

        public DataTable Dttb
        {
            //代 orgid machid
            get { return dal.Inventorycheck(companyid, typeid); }
            set { dttb = value; }
        }


        #endregion

        #region 电费收入
        bool addElectricityTariff;

        public bool AddElectricityTariff
        {
            get { return dal.AddElectricityTariff(id, startDate, endDate, dueDate, income, amountPaid); }
            set { addElectricityTariff = value; }
        }

        bool updateElectricityTariff;

        public bool UpdateElectricityTariff
        {
            get { return dal.EditElectricityTariff(id, startDate, endDate, dueDate, income, amountPaid); }
            set { updateElectricityTariff = value; }
        }

        bool deleteElectricityTariff;

        public bool DeleteElectricityTariff
        {
            get { return dal.DeleteElectricityTariff(id); }
            set { deleteElectricityTariff = value; }
        }

        #region 电费收入 分页
        DataTable electricPage;

        public DataTable ElectricPage
        {
            get { return dal.GetElectricPage(pCount, pInde, id, sTime, eTime); }
            set { electricPage = value; }
        }
        #endregion

        #region 电费收入 分页总数
        int electricPageCount;

        public int ElectricPageCount
        {
            get { return dal.GetElectricPageCount(id, sTime, eTime); }
            set { electricPageCount = value; }
        }
        #endregion

        #endregion

        #region 补贴和证书收入
        bool addSubsidy;

        public bool AddSubsidy
        {
            get { return dal.AddSubsidy(id, startDate, endDate, dueDate, income, amountPaid); }
            set { addSubsidy = value; }
        }

        bool updateSubsidy;

        public bool UpdateSubsidy
        {
            get { return dal.EditSubsidy(id, startDate, endDate, dueDate, income, amountPaid); }
            set { updateSubsidy = value; }
        }

        bool deleteSubsidy;

        public bool DeleteSubsidy
        {
            get { return dal.DeleteSubsidy(id); }
            set { deleteSubsidy = value; }
        }

        #region 补贴收入 分页
        DataTable subsidiesPage;
        public DataTable SubsidiesPage
        {
            get { return dal.GetSubsidiesPage(pCount, pInde, id, sTime, eTime); }
            set { subsidiesPage = value; }
        }
        #endregion

        #region 补贴收入总数
        int subsidiesPageCount;

        public int SubsidiesPageCount
        {
            get { return dal.GetSubsidiesPageCount(id, sTime, eTime); }
            set { subsidiesPageCount = value; }
        }
        #endregion
        #endregion

        #region 运维预付费
        bool addOMPrepayment;

        public bool AddOMPrepayment
        {
            get { return dal.AddOMPrepayment(id, startDate, endDate, income, amountPaid); ; }
            set { addOMPrepayment = value; }
        }

        bool updateOMPrepayment;

        public bool UpdateOMPrepayment
        {
            get { return dal.EditOMPrepayment(id, startDate, endDate, income, amountPaid); }
            set { updateOMPrepayment = value; }
        }

        bool deleteOMPrepayment;

        public bool DeleteOMPrepayment
        {
            get { return dal.DeleteOMPrepayment(id); }
            set { deleteOMPrepayment = value; }
        }

        bool checkOMPrepayment;

        public bool CheckOMPrepayment
        {
            get { return dal.CheckIsExitOMPrepayment(idKey, id, date); }
            set { checkOMPrepayment = value; }
        }

        #region 运维预付费用 分页
        DataTable pepaymentomPage;

        public DataTable PepaymentomPage
        {
            get { return dal.GetPepaymentomPage(pCount, pInde, id, sTime, eTime); }
            set { pepaymentomPage = value; }
        }
        int prepaymentOMPageCount;

        public int PrepaymentOMPageCount
        {
            get { return dal.GetPepaymentomPageCount(id, sTime, eTime); }
            set { prepaymentOMPageCount = value; }
        }
        #endregion
        #endregion

        #region 设备预付费

        bool addEQPrepayment;

        public bool AddEQPrepayment
        {
            get { return dal.AddEquipmentPrepayment(orgid, userName, startDate, machineId, quantity, unitPrice, warrantyPeroid, warrantyDate, contractName, contractPhone, contractEmail); }
            set { addEQPrepayment = value; }
        }

        bool deleteEQPrepayment;

        bool updateEQPrepayment;

        public bool UpdateEQPrepayment
        {
            get { return dal.UpdateEquipmentPrepayment(orgid, userName, startDate, machineId, quantity, unitPrice, warrantyPeroid, warrantyDate, contractName, contractPhone, contractEmail); }
            set { updateEQPrepayment = value; }
        }

        public bool DeleteEQPrepayment
        {
            get { return dal.DeleteEquipmentPrepayment(id); }
            set { deleteEQPrepayment = value; }
        }
        #endregion

        #region 设备更换
        bool addEQReplace;

        public bool AddEQReplace
        {
            get { return dal.AddEquipmentReplace(orgid, userName, startDate, machineId, quantity, unitPrice, warrantyPeroid, warrantyDate, contractName, contractPhone, contractEmail); }
            set { addEQReplace = value; }
        }

        bool updateEQReplace;

        public bool UpdateEQReplace
        {
            get { return dal.UpdateEquipmentReplace(orgid, userName, startDate, machineId, quantity, unitPrice, warrantyPeroid, warrantyDate, contractName, contractPhone, contractEmail); }
            set { updateEQReplace = value; }
        }

        bool deleteEQReplace;

        public bool DeleteEQReplace
        {
            get { return dal.DeleteEquipmentReplace(id); ; }
            set { deleteEQReplace = value; }
        }


        #endregion

        #region 初始资本支出
        bool addInitialCapex;

        public bool AddInitialCapex
        {
            get { return dal.AddInitialCapex(orgid, userName, startDate, machineId, quantity, unitPrice, warrantyPeroid, warrantyDate, contractName, contractPhone, contractEmail); }
            set { addInitialCapex = value; }
        }

        bool updateInitialCapex;

        public bool UpdateInitialCapex
        {
            get { return dal.UpdateInitialCapex(orgid, userName, startDate, machineId, quantity, unitPrice, warrantyPeroid, warrantyDate, contractName, contractPhone, contractEmail); }
            set { updateInitialCapex = value; }
        }

        bool deleteInitialCapex;

        public bool DeleteInitialCapex
        {
            get { return dal.DeleteInitialCapex(id); ; }
            set { deleteInitialCapex = value; }
        }
        #endregion

        #region 设备采购
        bool addEquipmentProcure;

        public bool AddEquipmentProcure
        {
            get { return dal.AddEquipmentProcure(orgid, quantity, machineId, date, paymentAmount, dueDate); }
            set { addEquipmentProcure = value; }
        }

        bool updateEquipmentProcure;

        public bool UpdateEquipmentProcure
        {
            get { return dal.UpdateEquipmentProcure(orgid, quantity, machineId, date, paymentAmount, dueDate); }
            set { updateEquipmentProcure = value; }
        }

        private bool deleteEquipmentProcure;

        public bool DeleteEquipmentProcure
        {
            get { return dal.DeleteEquipmentProcure(id); }
            set { deleteEquipmentProcure = value; }
        }
        #endregion

        #region 工资福利
        bool addSalaryWelfare;

        public bool AddSalaryWelfare
        {
            get { return dal.AddSalaryWelfare(orgid, typeId, paymentAmount, dueDate); }
            set { addSalaryWelfare = value; }
        }

        bool updateSalaryWelfare;

        public bool UpdateSalaryWelfare
        {
            get { return dal.UpdateSalaryWelfare(orgid,typeId,paymentAmount,dueDate); }
            set { updateSalaryWelfare = value; }
        }

        bool deleteSalaryWelfare;

        public bool DeleteSalaryWelfare
        {
            get { return dal.DeleteSalaryWelfare(id); }
            set { deleteSalaryWelfare = value; }
        }

        DataTable dtSalaryType;

        public DataTable DtSalaryType
        {
            get { return dal.GetSalaryWelfareType(); }
            set { dtSalaryType = value; }
        }
        #endregion

        #region 设备信息
        DataTable dtEquipmentCompany;

        public DataTable DtEquipmentCompany
        {
            get { return dal.GetEquipmentCompany(id); }
            set { dtEquipmentCompany = value; }
        }

        DataTable dtEquipmentType;

        public DataTable DtEquipmentType
        {
            get { return dal.GetEquipmentType(); }
            set { dtEquipmentType = value; }
        }

        private DataTable dtEquipmentModel;

        public DataTable DtEquipmentModel
        {
            get { return dal.GetEquipmentModel(idKey, id); }
            set { dtEquipmentModel = value; }
        }
        #endregion

    }
}
